import { uniqueId } from 'lodash'

/**
 * @description 给菜单数据补充上 path 字段
 * @description https://github.com/d2-projects/d2-admin/issues/209
 * @param {Array} menu 原始的菜单数据
 */
function supplementPath (menu) {
  return menu.map(e => ({
    ...e,
    path: e.path || uniqueId('d2-menu-empty-'),
    ...e.children ? {
      children: supplementPath(e.children)
    } : {}
  }))
}

// 顶部导航栏
export const menuHeader = supplementPath([
  { path: '/index', title: '首页', icon: 'home' },
  { path: '/fyh_shop', title: '商店管理', icon: 'shopping-bag' },
  {
    title: '订单管理',
    icon: 'folder-o',
    children: [
      { path: '/order/allOrder', title: '所有订单' },
      { path: '/order/pendingOrder', title: '待处理订单' }
    ]
  },
  {
    title: '用户管理',
    icon: 'folder-o',
    children: [
      { path: '/information', title: '信息管理' }
    ]
  }
])

// 侧边导航栏
export const menuAside = supplementPath([
  { path: '/index', title: '首页', icon: 'home' },
  { path: '/fyh_shop', title: '商店管理', icon: 'shopping-bag' },
  {
    title: '订单管理',
    icon: 'folder-o',
    children: [
      { path: '/order/allOrder', title: '所有订单' },
      { path: '/order/pendingOrder', title: '待处理订单' }
    ]
  },
  {
    title: '用户管理',
    icon: 'folder-o',
    children: [
      { path: '/information', title: '信息管理' }

    ]
  }
])
